<template>
	<view class="content cxxx">
		<view class="banner">
			<view class="logo"  :style="{top:navBarTop + 'px'}">
				<image src="../../static/logo.png" mode=""></image>
			</view>
			
			<swiper @click="goPagee" class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" 
			:duration="duration" indicator-active-color="rgba(255,255,255,0.7)" indicator-color="rgba(255,255,255,0.7)">
				<swiper-item v-for="(item,index) in bannerList" :key="index">
					<image :src="item.imageUrl" mode=""></image>
				</swiper-item>
			</swiper>
		</view>
		
		<view class="wrap">
			<view class="serviceBox">
				<view class="service-title">
					预约服务
				</view>
				<view class="serviceList">
					<view class="serviceli" @click="goDetail(item)" v-for="(item,index) in typeList" :key="index">
						<image :src="'../../static/fu'+(index + 1)+'.png'" mode=""></image>
					</view>
				</view>
			</view>
			
			<view class="queryBox">
				<view class="service-title">
					查询服务
				</view>
				
				<view class="queryList">
					<view class="qyFirst" @click="goStand(2)">
						<image src="https://czjy.jorse.xyz/images/service1.png" mode=""></image>
					</view>
					<view class="qyInfo">
						<view class="qyli" @click="goStand(1)">
							<image src="https://czjy.jorse.xyz/images/service2.png" mode=""></image>
						</view>
						<view class="qyli" @click="goStand(0)">
							<image src="https://czjy.jorse.xyz/images/service3.png" mode=""></image>
						</view>
					</view>
					
				</view>
			</view>
			
			<view class="companyBox">
				<view class="company-title">
					公司介绍
				</view>
				<view class="companyInfo">
					<u-parse :content="content"></u-parse>
				</view>
			</view>
			
		</view>
		
		<!-- <button open-type="getUserProfile" @tap="getUserProfileTwo">获取微信昵称和头像</button> -->

		<bottomPage :suo="0" v-if="isHide"></bottomPage>
		
		<otherBottom :suo="0" v-else></otherBottom>
		
	</view>
</template>

<script>
	import { getBannerList, loginForm, getDict, getServerContext, setUserInfo, getArticleInfo, 
			getUserInfoDetail, updateUserInfo } from '@/api/login.js';
	import bottomPage from '@/components/bottom.vue';
	import otherBottom from '@/components/otherBottom.vue';
	import baseUrl  from '@/util/config.js';
	export default {
		components:{
			bottomPage, otherBottom
		},
		data() {
			return {
				isHide: true,
				show: false,
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				navBarTop: null,
				bannerList: [],
				typeList: [],
				standList: [],
				content: '',
				
			}
		},
		onLoad() {
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
			this.navBarTop = menuButtonInfo.top;
			// this.getBanner();
			// this.getTypeDict();
			// this.getStand();
			// this.getCompanyInfo();
			this.commonMethods();
			return;
			if(uni.getStorageSync('userToken') == '') {
				// uni.login({
				// 	provider: 'weixin', //使用微信登录
				// 	success:ress=> {
				// 		console.log(ress);
				// 		loginForm({code:ress.code}).then(res=>{
				// 			uni.setStorageSync('userToken',res.data.token);
				// 			uni.setStorageSync('needReg',res.data.needReg);
				// 			uni.setStorageSync('openId',res.data.openId);
				// 			uni.setStorageSync('userInfo',res.data.wxUser);
				// 			if(res.data.wxUser.phone == null) {
				// 				this.show = true;
				// 			} else {
				// 				this.show = false;
				// 				this.commonMethods();
				// 			}
				// 		});
				// 	}
				// });
			} else {
				if(uni.getStorageSync('userInfo').phone == null) {
					this.show = true;
				} else {
					this.show = false;
					this.commonMethods();
				}
			}	
		},
		methods: {
			watermarkCallback(filePath) {//水印添加回调，在H5平台下，filePath 为 base64
				console.log(filePath,'----')
			},
			getUserProfileTwo(){
				uni.getUserProfile({
					desc: '用于完善用户资料', // 声明用途
					success: (res) => {
					  console.log('用户信息获取成功', res);
					},
					fail: (err) => {
					  console.error('用户信息获取失败', err);
					}
				});
			},
			goPagee(){
				
			},
			getCompanyInfo(){
				getArticleInfo(14).then(res=>{
					if(res.code == 200) {
						this.content = res.data.articleContext;
					} else {
						uni.$u.toast(res.msg);
					}
				});
			},
			goStand(index){
				if(uni.getStorageSync('userInfo').isMaster == 1) {
					uni.switchTab({
						url: '/pages/engineer/index'
					})
				} else {
					uni.navigateTo({
						url: '/pages/index/standDetail?idd=' + this.standList[index].id
					});
				}
				return;
				this.commonLogin(3,index);
				return;
				if(uni.getStorageSync('userInfo').isMaster == 1) {
					uni.switchTab({
						url: '/pages/engineer/index'
					})
				} else {
					uni.navigateTo({
						url: '/pages/index/standDetail?idd=' + this.standList[index].id
					})
				}
				
			},
			commonMethods(){
				this.getBanner();
				this.getTypeDict();
				this.getStand();
				this.getCompanyInfo();
				if(uni.getStorageSync('userInfo').isMaster == 1) {
					console.log(1234123431234)
					this.isHide = false;
				} else {
					this.isHide = true;
				}
			},
			getStand(){
				getServerContext().then(res=>{
					if(res.code == 200) {
						this.standList = res.rows;
					} else{
						uni.$u.toast(res.msg);
					}
				})
			},
			getBanner(){
				getBannerList().then(res=>{
					if(res.code == 200) {
						this.bannerList = res.rows;
					} else {
						uni.$u.toast(res.msg);
					}
				})
			},
			getTypeDict(){
				getDict({dictType: 'kt_service_type'}).then(res=>{
					if(res.code == 200) {
						this.typeList = res.rows;
					} else{
						uni.$u.toast(res.msg);
					}
				})
			},
			commonLogin(type,val){
				if(uni.getStorageSync('isLogout') == 1) {
					if(uni.getStorageSync('userInfo').isMaster == 1) {
						uni.switchTab({
							url: '/pages/engineer/mine'
						});
					} else {
						uni.switchTab({
							url: '/pages/mine/index'
						});
					}	
				} else {
					if(uni.getStorageSync('userInfo').isMaster == 1) {
						uni.switchTab({
							url: '/pages/engineer/index'
						})
					} else {
						if(type == 1) {
							uni.navigateTo({
								url: '/pages/index/service?idd=' + val.dictValue
							});
						} else if(type == 2){
							uni.navigateTo({
								url:'/pages/mine/deviceInfo'
							})
						} else if(type == 3){
							uni.navigateTo({
								url: '/pages/index/standDetail?idd=' + this.standList[val].id
							})
						}	
					}
				}
			},
			goDetail(val){
				if(uni.getStorageSync('userInfo').isMaster == 1) {
					uni.switchTab({
						url: '/pages/engineer/index'
					})
				} else {
					uni.navigateTo({
						url: '/pages/index/service?idd=' + val.dictValue
					});
				}
				return;
				this.commonLogin(1,val);
				return;
				getUserInfoDetail({id: uni.getStorageSync('userInfo').id}).then(res=>{
					if(res.data.companyId == null) {
						uni.navigateTo({
							url: '/pages/mine/joinUs?type=1'
						});
					} else {
						if(res.data.companyName == null) {
							uni.$u.toast('请等待审核！');
						} else {
							
						}
						
					}
				});
			},
			goCart(){
				this.commonLogin(2);
				return;
				if(uni.getStorageSync('userInfo').isMaster == 1) {
					uni.switchTab({
						url: '/pages/engineer/index'
					})
				} else {
					uni.navigateTo({
						url:'/pages/mine/deviceInfo'
					})
				}	
				
			}
		}
	}
</script>

<style scoped lang="scss">
.content {
	
	.wrap{
		background-color:#F4F5F7;padding:24rpx;
		.companyBox{
			background-color:#fff;border-radius:20rpx;box-shadow: 0px 8rpx 8rpx 0px #00000003;padding:0 24rpx 32rpx;
			.company-title{
				@include baseFont(32rpx,#333,40rpx);font-weight:500;padding:28rpx 0 14rpx;
			}
		}
		.queryBox{
			background-color:#fff;border-radius:20rpx;box-shadow: 0px 8rpx 8rpx 0px #00000003;padding:0 24rpx 32rpx;margin:16rpx 0;
			.service-title{
				@include baseFont(32rpx,#333,40rpx);font-weight:500;padding:28rpx 0 14rpx;
			}
			.queryList{
				@include flx;justify-content: space-between;
				.qyFirst{
					width:316rpx;height:264rpx;
					image{
						display: block;width:100%;height:100%;
					}
				}
				.qyInfo{
					.qyli{
						width:318rpx;height:120rpx;
						image{
							display: block;width:100%;height:100%;
						}
					}
					.qyli:first-of-type{
						margin-bottom:24rpx;
					}
				}
			}
		}
		.serviceBox{
			background-color:#fff;border-radius:20rpx;box-shadow: 0px 8rpx 8rpx 0px #00000003;
			padding:0 24rpx 32rpx;
			.service-title{
				@include baseFont(32rpx,#333,40rpx);font-weight:500;padding:28rpx 0 14rpx;
			}
			.serviceList{
				@include flx;align-items: flex-end;justify-content: space-between;
				.serviceli{
					width:150rpx;height:131rpx;display: flex;align-items: flex-end;
					image{
						display: block;width:100%;height:100%;
					}
				}
				.serviceli:nth-of-type(2){
					height:132rpx;
				}
				.serviceli:nth-of-type(3){
					height:132rpx;
				}
				.serviceli:nth-of-type(3){
					height:142rpx;
				}
			}
		}
		.companyBox{
			.company-title{
				@include baseFont(28rpx,#333,48rpx);
				font-weight:500;
			}
			.companyInfo{
				@include baseFont(28rpx,#4C4C4C,44rpx);
			}
		}
	}
	.banner{
		position: relative;
		.logo{
			position: absolute;top: 94rpx;left:66rpx;z-index: 999;
			image{
				display: block;width:216rpx;height:56rpx;
			}
		}
		.swiper{
			width:100%;height:428rpx;
			image{
				display: block;width:100%;height:100%;
			}
		}
	}
}
</style>
